package com.itlong.cloud.controller.upgrade;

import com.itlong.cloud.POJO.DTO.operate.OperateDeviceInfoGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateDeviceManageGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateHardwareDeviceUpdateDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateHardwareProjectGetPageDTO;
import com.itlong.cloud.POJO.PO.OperateUserInfoPO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.POJO.VO.operate.*;
import com.itlong.cloud.annotation.AuthAccessRequired;
import com.itlong.cloud.annotation.LoggerInfo;
import com.itlong.cloud.annotation.UnAuthAccessRequired;
import com.itlong.cloud.constants.LogDescConstant;
import com.itlong.cloud.constants.RedisConstant;
import com.itlong.cloud.controller.system.OperateFunctionController;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import com.itlong.cloud.enumerate.ecode.OperateErrorCodeEnum;
import com.itlong.cloud.equip.operate.IOperateDeviceManageServiceClient;
import com.itlong.cloud.equip.operate.IOperateHardwareServiceClient;
import com.itlong.cloud.equip.operate.IOperatePackageServiceClient;
import com.itlong.cloud.service.RedisService;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.user.operate.IOperateUserInfoServiceClient;
import com.itlong.cloud.utils.network.http.HttpProtocolUtil;
import com.itlong.cloud.utils.page.Page;
import com.itlong.cloud.utils.words.StringHandlerUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * <desc>
 * 运营-固件升级-设备升级管理控制器
 * </desc>
 *
 * @createDate 2018/08/22
 */
@RestController
@RequestMapping("/upgrade/hardware")
public class OperateHardwareController {
    private static final Logger LOG = LoggerFactory.getLogger(OperateFunctionController.class);

    @Autowired
    IOperateHardwareServiceClient iOperateHardwareServiceClient;
    @Autowired
    IOperatePackageServiceClient operatePackageServiceClient;

    @Autowired
    IOperateUserInfoServiceClient userInfoServiceClient;

    @Autowired
    RedisService redisService;

    @Autowired
    IOperatePackageServiceClient iOperatePackageServiceClient;


    @Autowired
    IOperateDeviceManageServiceClient iOperateDeviceManageServiceClient;

    /**
     * <desc>
     * 分页获取设备信息
     * <desc/>
     *
     * @param operateUpdateInfoGetPageDTO 查询参数DTO
     * @return
     * @author Qiang.S
     * @createDate 2018-08-27
     */
    @RequestMapping(value = "/getDeviceInfoPage", method = RequestMethod.POST)
    @ResponseBody
    public Object getDeviceInfoPage(OperateDeviceInfoGetPageDTO operateUpdateInfoGetPageDTO) {
        MessageVO messageVO;
        Set<String>  DeviceSet = new HashSet<>();
        //存储受限设备在线离线状态
        Map<String, Object> map = new HashMap<>();
        StringBuffer  deviceUniques=new StringBuffer();
        OperateDeviceManageGetPageDTO operateDeviceManageGetPageDTO = new OperateDeviceManageGetPageDTO();
        Map<String, Object> paramMap = new HashMap<>();
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            operateUpdateInfoGetPageDTO = HttpProtocolUtil.parseRequestParamToDTO(OperateDeviceInfoGetPageDTO.class, request);
            //判断参数合法性
            if (null == operateUpdateInfoGetPageDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(operateUpdateInfoGetPageDTO.getDeviceKind())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (operateUpdateInfoGetPageDTO.getProjectId() == null) {
                operateUpdateInfoGetPageDTO.setProjectId("");
            }
            if (StringUtils.isBlank(operateUpdateInfoGetPageDTO.getOrderColumn())) {
                operateUpdateInfoGetPageDTO.setOrderColumn("createTime");
                operateUpdateInfoGetPageDTO.setOrderRule("DESC");
            }

                //传入设备id，一个或者多个，和设备类型 一体式人脸识别平板

            if ("2".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云门禁时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("4");
                //受限设备云门禁
                List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                DeviceSet.addAll(spEntranceDeviceList);
            }
         /* 取消一体式云门禁新类别，直接在云门禁类别中展示
          if ("25".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//一体式云门禁时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("8");//查询一体式云门禁的在线离线状态
                //受限设备云门禁
                List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                DeviceSet.addAll(spEntranceDeviceList);
            }*/
            if ("23".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云联动器时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("6");
                //受限设备云门禁
                List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                DeviceSet.addAll(spEntranceDeviceList);
            }
            //3,云对讲;12云电梯;2云门禁;23云联动器;4人脸识别仪
            if ("3".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云对讲时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("1");
            }
            if ("12".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云电梯时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("2");
                //受限设备云电梯
                List<String> spElevatorDeviceList = iOperateHardwareServiceClient.getSpElevatorList();
                DeviceSet.addAll(spElevatorDeviceList);

            }

            if ("4".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("3");
                //获取受限设备平板
                List<String> spPadDeviceList = iOperateHardwareServiceClient.getSpPadList();
                DeviceSet.addAll(spPadDeviceList);
            }

            if ("24".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪一体式时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("7");
                //受限设备云门禁
                List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                DeviceSet.addAll(spEntranceDeviceList);

            }

            if ("5".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//群控器时重新处理返回数据
                operateDeviceManageGetPageDTO.setDeviceType("5");
                //获取受限的云群控器在线离线状态
                List<String> spControllerDeviceList = iOperateHardwareServiceClient.getSpControllerList();
                DeviceSet.addAll(spControllerDeviceList);
            }

            //当参数传入在线或者离线状态进行筛选时,如果不传值就是查所有状态
            operateDeviceManageGetPageDTO.setIsOnline(operateUpdateInfoGetPageDTO.getIsOnline());
            operateDeviceManageGetPageDTO.setPageSize("10000");

            //查询出设备的在线离线状态
            OperateDeviceManageInfoAllVO deviceByPage = iOperateDeviceManageServiceClient.getDeviceByPage(operateDeviceManageGetPageDTO);
            Page<OperateDeviceManageInfoVO> OnlinePage = deviceByPage.getPage();
            if (OnlinePage.getRows().size() != 0) {

                List<OperateDeviceManageInfoVO> rows = OnlinePage.getRows();
                //得到不受限的设备在线状态和设备id
                for (OperateDeviceManageInfoVO OperateDeviceManageInfoVO : rows) {
                    paramMap.put(OperateDeviceManageInfoVO.getDeviceUnique(), OperateDeviceManageInfoVO.getIsOnline());
                    deviceUniques.append(OperateDeviceManageInfoVO.getDeviceUnique()).append(",");
                }

            }
            if ("1".equals(operateUpdateInfoGetPageDTO.getIsOnline()) || "0".equals(operateUpdateInfoGetPageDTO.getIsOnline())){
                for (String deviceUnique : DeviceSet) {
                    deviceUniques.append(deviceUnique).append(",");
                }

              //获取受限设备
              operateUpdateInfoGetPageDTO.setDeviceUniqueList(deviceUniques + "");

             }

            Page<OperateDeviceInfoVO> page = iOperateHardwareServiceClient.getDeviceInfoPage(operateUpdateInfoGetPageDTO);

            Page<List<OperateDeviceInfoVO>> pageDoor = new Page<>();
            List<List<OperateDeviceInfoVO>> listAll = new ArrayList<>();
            if ("2".equals(operateUpdateInfoGetPageDTO.getDeviceKind()) || "23".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云门禁时重新处理返回数据
                List<OperateDeviceInfoVO> list = page.getRows();
                Map<String,List<OperateDeviceInfoVO>> mapList = new HashMap<>();
                for(OperateDeviceInfoVO deviceInfoVO : list){
                    String sn = deviceInfoVO.getSn();
                    if(mapList.containsKey(sn)){
                        List<OperateDeviceInfoVO> deviceInfoVOList = mapList.get(sn);
                        deviceInfoVOList.add(deviceInfoVO);
                        mapList.put(sn,deviceInfoVOList);
                    }else{
                        List<OperateDeviceInfoVO> deviceInfoVOList = new ArrayList<>();
                        deviceInfoVOList.add(deviceInfoVO);
                        mapList.put(sn,deviceInfoVOList);
                    }
                }
                if(mapList!=null&&mapList.size()>0){
                    for(List<OperateDeviceInfoVO> listVO : mapList.values()){
                        listAll.add(listVO);
                    }
                }
                pageDoor.setPage(page.getPage());
                pageDoor.setRows(listAll);

                //组装设备在线离线状态
                String[] unique = new String[listAll.size()];

                for (OperateDeviceInfoVO operateDeviceInfoVO : list) {
                    unique = operateDeviceInfoVO.getDeviceUnique().split(",");
                }

                operateDeviceManageGetPageDTO.setDeviceUnique(unique.toString());


                if ("2".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云门禁时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("4");
                    //受限设备云门禁
                    List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                    DeviceSet.addAll(spEntranceDeviceList);
                }
                if ("23".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云联动器时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("6");
                    //受限设备云门禁
                    List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                    DeviceSet.addAll(spEntranceDeviceList);
                }

                //将获取的受限设备放入缓存中查询
                for (String deviceUnique : DeviceSet) {
                    if (deviceUnique.length()!=0){
                       if ("2".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云门禁时重新处理返回数据DEVICE_LIMITED_ENTRANCE_IS_ONLINE_KEY_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_LIMITED_ENTRANCE_IS_ONLINE_KEY + deviceUnique);
                           map.put(deviceUnique,isOnlin);
                       }
                       if ("23".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//联动器时重新处理返回数据 DEVICE_LIMITED_WIPPEN_IS_ONLINE_KEY_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_LIMITED_WIPPEN_IS_ONLINE_KEY+ deviceUnique);
                           map.put(deviceUnique,isOnlin);
                       }
                    }
                }

                //组装最后的返回的数据结构
                List<List<OperateDeviceInfoVO>> rows = pageDoor.getRows();
                for (List<OperateDeviceInfoVO> row : rows) {
                    for (OperateDeviceInfoVO vo : row) {
                        if (paramMap.containsKey(vo.getDeviceUnique())) {
                            vo.setIsOnline("1".equals(paramMap.get(vo.getDeviceUnique())+"")?"1":"0");
                        }

                        if (map.containsKey(vo.getDeviceUnique())) {
                            vo.setIsOnline("1".equals(map.get(vo.getDeviceUnique())+"")?"1":"0");
                        }
                        if (vo.getIsOnline()==null){
                            vo.setIsOnline("0");
                        }
                        //查询活跃时间的key DEVICE_NEW_UPDATE_CACHE_TIME
                        //将查询出来的设备在线状态存入缓存，等会详情页使用
                        String devicetime = redisService.getKeysForDevice(RedisConstant.DEVICE_NEW_UPDATE_CACHE_TIME + vo.getDeviceUnique());
                        if (StringUtils.isBlank(devicetime)){
                            vo.setUpdateCacheTime("");
                        }else {
                            Long timeLong = Long.parseLong(devicetime);
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                            vo.setUpdateCacheTime(sdf.format(timeLong));
                        }
                        redisService.set(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY+vo.getDeviceUnique(),RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY_TIME,vo.getIsOnline());
                    }
                }
                //进行在线查询条件的筛选  筛选出在线
                if (operateUpdateInfoGetPageDTO!=null && "1".equals(operateUpdateInfoGetPageDTO.getIsOnline())){
                   for (int i =rows.size()-1; i >=0 ; i--){
                        for (int j =rows.get(i).size()-1; j >=0 ; j--) {
                            if ("0".equals(rows.get(i).get(j).getIsOnline())){
                                rows.get(i).remove(j);
                                if (rows.get(i).size()==0){
                                    rows.remove(i);
                                }
                            }
                        }
                    }
                    pageDoor.setRows(rows,rows.size());
                }
                //筛选出离线
                if (operateUpdateInfoGetPageDTO!=null && "0".equals(operateUpdateInfoGetPageDTO.getIsOnline())){
                    for (int i =rows.size()-1; i >=0 ; i--){
                        for (int j =rows.get(i).size()-1; j >=0 ; j--) {
                            if ("1".equals(rows.get(i).get(j).getIsOnline())){
                                rows.get(i).remove(j);
                                if (rows.get(i).size()==0){
                                    rows.remove(i);
                                }
                            }
                        }
                    }
                    pageDoor.setRows(rows,rows.size());
                }
                List<List<OperateDeviceInfoVO>> listDoor = new ArrayList<>();
              for (int i=(Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage())-1)* Integer.parseInt(operateUpdateInfoGetPageDTO.getPageSize()) ;
                   i < (Integer.parseInt((operateUpdateInfoGetPageDTO.getPageSize()))* Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage()) >
                           pageDoor.getRows().size() ? pageDoor.getRows().size() :
                           (Integer.parseInt((operateUpdateInfoGetPageDTO.getPageSize()))* Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage())));
                   i++){
                  listDoor.add(pageDoor.getRows().get(i));
              }
                pageDoor.setRows(listDoor,pageDoor.getRows().size());
                return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), pageDoor);
            } else {
                //组装设备在线离线状态
                List<OperateDeviceInfoVO> list = page.getRows();
                String[] unique = new String[list.size()];

                for (OperateDeviceInfoVO operateDeviceInfoVO : list) {
                    unique = operateDeviceInfoVO.getDeviceUnique().split(",");
                }
                 operateDeviceManageGetPageDTO.setDeviceUnique(unique.toString());

                //3,云对讲;12云电梯;2云门禁;23云联动器;4人脸识别仪
                if ("3".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云对讲时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("1");
                }
                if ("12".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云电梯时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("2");
                    //受限设备云电梯
                    List<String> spElevatorDeviceList = iOperateHardwareServiceClient.getSpElevatorList();
                    DeviceSet.addAll(spElevatorDeviceList);

                }

                if ("4".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("3");
                    //获取受限设备平板
                    List<String> spPadDeviceList = iOperateHardwareServiceClient.getSpPadList();
                    DeviceSet.addAll(spPadDeviceList);
                }

                if ("24".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪一体式时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("7");

                    //受限设备云门禁
                    List<String> spEntranceDeviceList =iOperateHardwareServiceClient.getSpEntranceList();
                    DeviceSet.addAll(spEntranceDeviceList);

                }

                if ("5".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//群控器时重新处理返回数据
                    operateDeviceManageGetPageDTO.setDeviceType("5");
                    //获取受限的云群控器在线离线状态
                    List<String> spControllerDeviceList = iOperateHardwareServiceClient.getSpControllerList();
                    DeviceSet.addAll(spControllerDeviceList);
                }


                 //将获取的受限设备放入缓存中查询
                for (String deviceUnique : DeviceSet) {
                   if (deviceUnique.length()!=0){

                       if ("5".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//群控器时重新处理返回数据key DEVICE_LIMITED_CLUSTER_IS_ONLINE_KEY_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_LIMITED_CLUSTER_IS_ONLINE_KEY + deviceUnique);
                           map.put(deviceUnique,isOnlin);
                       }
                       if ("12".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//云电梯时重新处理返回数据 IOT_LIMITED_CLOUD_ELEVATOR_STATE_CACHE_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.REDIS_IOT_LIMITED_CLOUD_ELEVATOR_STATE_CACHE + deviceUnique);
                           map.put(deviceUnique,isOnlin);
                       }

                       if ("24".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪一体式时重新处理返回数据 DEVICE_LIMITED_ENTRANCE_IS_ONLINE_KEY_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_LIMITED_UNIBODY_FACE_IS_ONLINE_KEY + deviceUnique);
                           map.put(deviceUnique,isOnlin);

                       }

                       if ("4".equals(operateUpdateInfoGetPageDTO.getDeviceKind())) {//人脸识别仪时重新处理返回数据DEVICE_LIMITED_PAD_IS_ONLINE_KEY_
                           String isOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_LIMITED_PAD_IS_ONLINE_KEY + deviceUnique);
                           map.put(deviceUnique,isOnlin);

                       }

                   }
                }

                //组装最后的返回的数据结构
                for (OperateDeviceInfoVO vo : list) {
                    if (paramMap.containsKey(vo.getDeviceUnique())) {
                        vo.setIsOnline("1".equals(paramMap.get(vo.getDeviceUnique())+"")?"1":"0");
                    }
                    if (map.containsKey(vo.getDeviceUnique())) {
                        vo.setIsOnline("1".equals(map.get(vo.getDeviceUnique())+"")?"1":"0");
                    }
                    if (vo.getIsOnline()==null){
                        vo.setIsOnline("0");
                    }
                    //将查询出来的设备在线状态存入缓存，等会详情页使用
                    String devicetime = redisService.getKeysForDevice(RedisConstant.DEVICE_NEW_UPDATE_CACHE_TIME + vo.getDeviceUnique());
                    if (StringUtils.isBlank(devicetime)){
                        vo.setUpdateCacheTime("");
                    }else {
                        Long timeLong = Long.parseLong(devicetime);
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                        vo.setUpdateCacheTime(sdf.format(timeLong));
                    }
                    redisService.set(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY+vo.getDeviceUnique(),RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY_TIME,vo.getIsOnline());
                }
               //进行在线查询条件的筛选  筛选出在线
               if (operateUpdateInfoGetPageDTO!=null && "1".equals(operateUpdateInfoGetPageDTO.getIsOnline())){
                   for (int i =list.size()-1; i >=0 ; i--) {
                           if ("0".equals(list.get(i).getIsOnline())){
                               list.remove(i);
                           }
                   }
                   page.setRows(list,list.size());
               }
               //筛选出离线
                if (operateUpdateInfoGetPageDTO!=null && "0".equals(operateUpdateInfoGetPageDTO.getIsOnline())){
                    for (int i = list.size()-1; i >=0; i--) {
                        if ("1".equals(list.get(i).getIsOnline())){
                            list.remove(i);
                        }
                    }
                    page.setRows(list,list.size());
                }
                List<OperateDeviceInfoVO> listPage = new ArrayList<>();
                for (int i=(Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage())-1)* Integer.parseInt(operateUpdateInfoGetPageDTO.getPageSize()) ;
                     i < (Integer.parseInt((operateUpdateInfoGetPageDTO.getPageSize()))* Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage()) >
                             page.getRows().size() ? page.getRows().size() :
                             (Integer.parseInt((operateUpdateInfoGetPageDTO.getPageSize()))* Integer.parseInt(operateUpdateInfoGetPageDTO.getCurrentPage())));
                     i++){
                    listPage.add( page.getRows().get(i));
                }
                page.setRows(listPage);
                return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), page);
            }
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_分页获取设备信息getDeviceInfoPage】分页获取设备信息失败", e);
        }
        //return messageVO;
    }

    /**
     * <desc>
     * 根据项目编号获取设备更新时间
     * <desc/>
     *
     * @param projectId 项目编号
     * @return
     * @author Qiang.S
     * @createDate 2018-09-04
     */
    @RequestMapping(value = "/getUpgradeTimeByProjectId", method = RequestMethod.POST)
    @ResponseBody
    public Object getUpgradeTimeByProjectId(String projectId) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            projectId = request.getAttribute("projectId") == null ? null : request.getAttribute("projectId").toString();
            //判断参数合法性
            if (StringUtils.isBlank(projectId)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    (Object) iOperateHardwareServiceClient.getUpgradeTimeByProjectId(projectId));
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_根据项目编号获取更新时间getUpgradeTimeByProjectId】根据项目编号获取更新时间失败", e);
        }
        return messageVO;
    }

    /**
     *<desc>
     * 获取设备升级详情
     *</desc>
     *
     * @Author chengshican
     * @Date 2020-11-13 17:58
     * @Param deviceKind;  //设备类别(2云门禁;3,云对讲;4人脸识别仪;5群控群，7 一体式人脸识别门禁,12云电梯;23云联动器
     * @Return
     * @Exception
     *
     */
      @RequestMapping(value = "/getOperateHardwareDetailByDeviceUnique",method = RequestMethod.POST)
      @ResponseBody
      public Object  getOperateHardwareDetailByDeviceUnique(String deviceUnique,String deviceKind){
          MessageVO messageVO=null;
          try {
              HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
              deviceUnique = request.getAttribute("deviceUnique") == null ? null : request.getAttribute("deviceUnique").toString();
              deviceKind = request.getAttribute("deviceKind") == null ? null : request.getAttribute("deviceKind").toString();

              //判断参数合法性
              if (StringUtils.isBlank(deviceUnique)) {
                  return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
              }
              //判断参数合法性
              if (StringUtils.isBlank(deviceKind)) {
                  return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
              }
              //将查询出来的设备在线状态存入缓存，等会详情页使用
              String devicetime = redisService.getKeysForDevice(RedisConstant.DEVICE_NEW_UPDATE_CACHE_TIME +deviceUnique);

              //设备类别(2云门禁;3,云对讲;4人脸识别仪;5群控群，24 一体式人脸识别门禁,12云电梯;23云联动器
              switch (deviceKind) {
                  case "3" :  //云对讲
                      OperateDeviceInfoVO detail = iOperateHardwareServiceClient.getTalkeDetailByDeviceUnique(deviceUnique);
                      String TalkisOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                       if (StringUtils.isBlank(devicetime)){
                          detail.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          detail.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      detail.setIsOnline(TalkisOnlin);
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                                  (Object)detail);
                       return messageVO;
                  case "12" ://云电梯
                      OperateDeviceInfoVO Elevatordetail1 = iOperateHardwareServiceClient.getElevatorDetailByDeviceUnique(deviceUnique);
                      String ElevatorisOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);

                      Elevatordetail1.setIsOnline(ElevatorisOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          Elevatordetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          Elevatordetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)Elevatordetail1 );
                      return messageVO;

                  case "2" ://云门禁
                      OperateDeviceInfoVO EntranceDetail1 =  iOperateHardwareServiceClient.getEntranceDetailByDeviceUnique(deviceUnique);
                      String EntranceIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      EntranceDetail1.setIsOnline(EntranceIsOnlin);


                      if (StringUtils.isBlank(devicetime)){
                          EntranceDetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          EntranceDetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)EntranceDetail1);
                      return messageVO;

                  case "5" ://云群控器
                      OperateDeviceInfoVO ClusterDetail1 =  iOperateHardwareServiceClient.getClusterDetailByDeviceUnique(deviceUnique);
                      String ClusterIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      ClusterDetail1.setIsOnline(ClusterIsOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          ClusterDetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          ClusterDetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)ClusterDetail1 );
                      return messageVO;

                  case "23" ://云联动器
                      OperateDeviceInfoVO WippenDetail1 =  iOperateHardwareServiceClient.getWippenDetailByDeviceUnique(deviceUnique);
                      String WippenIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      WippenDetail1.setIsOnline(WippenIsOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          WippenDetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          WippenDetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object) WippenDetail1);
                      return messageVO;

                  case "4" ://人脸识别仪（平板）
                      OperateDeviceInfoVO PadDetail1 =   iOperateHardwareServiceClient.getPadDetailByDeviceUnique(deviceUnique);
                      String PadIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      PadDetail1.setIsOnline(PadIsOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          PadDetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          PadDetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)PadDetail1);
                      return messageVO;

                  case "24" ://一体式人脸门禁
                      OperateDeviceInfoVO UnibodyDetail1 =  iOperateHardwareServiceClient.getUnibodyDetailByDeviceUnique(deviceUnique);
                      String UnibodyIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      UnibodyDetail1.setIsOnline(UnibodyIsOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          UnibodyDetail1.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          UnibodyDetail1.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)UnibodyDetail1 );
                      return messageVO;
              /*    case "25" ://一体式云门禁
                      OperateDeviceInfoVO UnibodyEntrance =  iOperateHardwareServiceClient.getUnibodyEntranceDetailByDeviceUnique(deviceUnique);
                      String UnibodyEntranceIsOnlin = redisService.getKeysForDevice(RedisConstant.DEVICE_HARDWARE_LIST_IS_ONLINE_KEY + deviceUnique);
                      UnibodyEntrance.setIsOnline(UnibodyEntranceIsOnlin);

                      if (StringUtils.isBlank(devicetime)){
                          UnibodyEntrance.setUpdateCacheTime("");
                      }else {
                          Long timeLong = Long.parseLong(devicetime);
                          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
                          UnibodyEntrance.setUpdateCacheTime(sdf.format(timeLong));
                      }
                      messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                              (Object)UnibodyEntrance );
                      return messageVO;
*/
              }
          } catch (Exception e) {
              throw new DataAccessException("【运营_固件升级_根据项目编号获取更新时间getUpgradeTimeByProjectId】根据项目编号获取更新时间失败", e);
          }
          return messageVO;
    }



    /**
     * <desc>
     * 按条件分页获取项目列表
     * <desc/>
     *
     * @param operateHardwareProjectGetPageDTO 查询参数DTO
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @RequestMapping(value = "/getProjectInfoPage", method = RequestMethod.POST)
    @ResponseBody
    public Object getProjectInfoPage(OperateHardwareProjectGetPageDTO operateHardwareProjectGetPageDTO) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            operateHardwareProjectGetPageDTO = HttpProtocolUtil.parseRequestParamToDTO(OperateHardwareProjectGetPageDTO.class, request);
            //判断参数合法性
            if (null == operateHardwareProjectGetPageDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iOperateHardwareServiceClient.getProjectInfoPage(operateHardwareProjectGetPageDTO));
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_分页获取项目信息getProjectInfoPage】分页获取项目信息失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     * 查询项目楼栋列表
     * <desc/>
     *
     * @param projectId 项目编号
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @RequestMapping(value = "/getBuildInfo", method = RequestMethod.POST)
    @ResponseBody
    public Object getBuildInfo(String projectId) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            projectId = request.getAttribute("projectId") == null ? null : request.getAttribute("projectId").toString();
            //判断参数合法性
            if (StringUtils.isBlank(projectId)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iOperateHardwareServiceClient.getBuildInfo(projectId));
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_查询项目下楼栋列表getProjectInfoPage】查询项目下楼栋列表失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     * 查询项目单元列表
     * <desc/>
     *
     * @param projectId 项目编号
     * @param buildId   楼栋编号
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @RequestMapping(value = "/getUnitInfo", method = RequestMethod.POST)
    @ResponseBody
    public Object getUnitInfo(String projectId, String buildId) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            projectId = request.getAttribute("projectId") == null ? null : request.getAttribute("projectId").toString();
            buildId = request.getAttribute("buildId") == null ? null : request.getAttribute("buildId").toString();
            //判断参数合法性
            if (StringUtils.isBlank(projectId)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(buildId)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iOperateHardwareServiceClient.getUnitInfo(projectId, buildId));
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_查询项目单元列表getProjectInfoPage】查询项目单元列表失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     * 设置项目设备更新时间
     * <desc/>
     *
     * @param projectId   项目编号
     * @param upgradeTime 项目设备升级时间
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @RequestMapping(value = "/setupUpdateTime", method = RequestMethod.POST)
    @AuthAccessRequired
    @LoggerInfo(operateDesc = LogDescConstant.SET_DEVICE_UPDATETIME_LOG_DESC)
    @ResponseBody
    public Object setupUpdateTime(String projectId, String upgradeTime) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            projectId = request.getAttribute("projectId") == null ? null : request.getAttribute("projectId").toString();
            upgradeTime = request.getAttribute("upgradeTime") == null ? null : request.getAttribute("upgradeTime").toString();
            //判断参数合法性
            if (StringUtils.isBlank(projectId)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(upgradeTime)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            iOperateHardwareServiceClient.setupUpdateTime(projectId, upgradeTime);
            messageVO = new MessageVO(projectId, BaseErrorCodeEnum.SUCCESS.getErrorCode());
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_设置项目设备更新时间setupUpdateTime】设置项目设备更新时间失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     * 设备更新
     * <desc/>
     *
     * @param operateHardwareDeviceUpdateDTO 设备更新信息
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @RequestMapping(value = "/deviceUpdate", method = RequestMethod.POST)
    @AuthAccessRequired
    @LoggerInfo(operateDesc = LogDescConstant.DEVICE_UPDATETIME_LOG_DESC)
    @ResponseBody
    public Object deviceUpdate(OperateHardwareDeviceUpdateDTO operateHardwareDeviceUpdateDTO) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            operateHardwareDeviceUpdateDTO = HttpProtocolUtil.parseRequestParamToDTO(OperateHardwareDeviceUpdateDTO.class, request);
            //判断参数合法性
            if (null == operateHardwareDeviceUpdateDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(operateHardwareDeviceUpdateDTO.getDeviceUniques())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(operateHardwareDeviceUpdateDTO.getDeviceInfo())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(operateHardwareDeviceUpdateDTO.getDeviceKind())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(operateHardwareDeviceUpdateDTO.getUpdateId())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            OperateUpdateDetailVO detail = operatePackageServiceClient.getUpdateDetail(operateHardwareDeviceUpdateDTO.getUpdateId());
            if ("0".equals(operateHardwareDeviceUpdateDTO.getGoOnflag())) {
                if ("".equals(detail.getProductCode()) || detail.getProductCode()==null) {
                    return new MessageVO(OperateErrorCodeEnum.PACKAGE_NOT_MATCH.getErrorCode());
                }
                if (!"".equals(detail.getProductCode())) {
                    List<String> list = Arrays.asList(detail.getProductCode().split(","));
                    List<String> paramList = Arrays.asList(operateHardwareDeviceUpdateDTO.getProductCodes().split(","));
                    Set<String> set = new HashSet<>(paramList);
                    //判断锁选中的设备产品型号是否在安装包适用的产品型号范围内
                    boolean flag = list.containsAll(set);
                    if (!flag) {
                        return new MessageVO(OperateErrorCodeEnum.PACKAGE_NOT_MATCH.getErrorCode());
                    }
                }

            }

            //设置设备的升级时间
            String formatDate=null;
            if (operateHardwareDeviceUpdateDTO.getUpgradeTime()==null||operateHardwareDeviceUpdateDTO.getUpgradeTime()==""){
                Date date = new Date();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                formatDate = formatter.format(date);
            }
            String ip = HttpProtocolUtil.getIpAddr(request);
            operateHardwareDeviceUpdateDTO.setIp(ip);
            OperateUserInfoPO user=userInfoServiceClient.retrieve(operateHardwareDeviceUpdateDTO.getToken());
            operateHardwareDeviceUpdateDTO.setLoginUserId(user.getUserId());
            operateHardwareDeviceUpdateDTO.setUpgradeTime(((operateHardwareDeviceUpdateDTO.getUpgradeTime()==null||  "".equals(operateHardwareDeviceUpdateDTO.getUpgradeTime())?formatDate:operateHardwareDeviceUpdateDTO.getUpgradeTime())));
            iOperateHardwareServiceClient.deviceUpdate(operateHardwareDeviceUpdateDTO);


          if (null!=operateHardwareDeviceUpdateDTO.getProjectId()){
              List<String> list = Arrays.asList(operateHardwareDeviceUpdateDTO.getProjectId().split(","));
              Set<String> hashSet = new HashSet<>();
              hashSet.addAll(list);
              for (String projectId : hashSet) {
                  iOperateHardwareServiceClient.setupUpdateTime(projectId, ((operateHardwareDeviceUpdateDTO.getUpgradeTime()==null|| "".equals(operateHardwareDeviceUpdateDTO.getUpgradeTime()))?formatDate:operateHardwareDeviceUpdateDTO.getUpgradeTime()));
              }
          }
               messageVO = new MessageVO(operateHardwareDeviceUpdateDTO.getDeviceUniques() + "|" + operateHardwareDeviceUpdateDTO.getUpdateId(),
                    BaseErrorCodeEnum.SUCCESS.getErrorCode());
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_设备更新deviceUpdate】设备更新失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     * 通过设备类型查询安装包接口
     * </desc>
     *
     * @Author chengshican
     * @Date 2020-11-12 10:05
     * @Param 产品类型 0云电梯，1云对讲，2云门禁，3群控器，4联动器，5人脸识别仪，6一体式人脸识别门禁 7一体式云门禁
     * @Return
     * @Exception
     */
    @RequestMapping(value = "/getPackageNameByProductType", method = RequestMethod.POST)
    @UnAuthAccessRequired
    @LoggerInfo(operateDesc = LogDescConstant.DEVICE_UPDATETIME_LOG_DESC)
    @ResponseBody
    public Object getPackageNameByProductType(String productTypes,String deviceType) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            productTypes = request.getAttribute("productTypes") == null ? null : request.getAttribute("productTypes").toString();
            deviceType = request.getAttribute("deviceType") == null ? null : request.getAttribute("deviceType").toString();

            //判断参数合法性
            if (StringUtils.isBlank(productTypes)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            //判断参数合法性
            if (StringUtils.isBlank(deviceType)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            List<OperateUpdateInfoVO> list = iOperateHardwareServiceClient.getPackageNameByProductType(productTypes,deviceType);
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), list);
        } catch (Exception e) {
            throw new DataAccessException("【运营_固件升级_设置项目设备更新时间setupUpdateTime】设置项目设备更新时间失败", e);
        }
        return messageVO;


    }
    /**
     *<desc>
     * 分页获取特殊操作日志
     *</desc>
     *
     * @Author  chengshican
     * @Date   2020-11-10 18:41
     * @Param  deviceUnique 对应操作数据id(更新文件编号)
     * @Return
     * @Exception
     *
     */
    @RequestMapping(value = "/getOperationSpecialLogList", method = RequestMethod.POST)
    @ResponseBody
    @UnAuthAccessRequired
    public Object getOperationSpecialLogList(String deviceUnique, String pageSize, String currentPage ,String orderColumn,String orderRule){
        MessageVO messageVO;
        try{
            HttpServletRequest request= ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            deviceUnique=request.getAttribute("deviceUnique")==null?null:request.getAttribute("deviceUnique").toString();
            pageSize=request.getAttribute("pageSize")==null?null:request.getAttribute("pageSize").toString();
            currentPage=request.getAttribute("currentPage")==null?null:request.getAttribute("currentPage").toString();
            orderColumn=request.getAttribute("orderColumn")==null?null:request.getAttribute("orderColumn").toString();
            orderRule=request.getAttribute("orderRule")==null?null:request.getAttribute("orderRule").toString();

            //判断参数合法性
            if (StringUtils.isBlank(deviceUnique)){
                return new MessageVO(OperateErrorCodeEnum.PACKAGE_UPDATE_ID_EMPTY_ERR.getErrorCode());
            }
            messageVO=new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), iOperatePackageServiceClient.getOperationSpecialLogList(deviceUnique,pageSize,currentPage,orderColumn,orderRule));
        }catch (Exception e){
            throw new DataAccessException("【运营_固件升级_获取分页获取特殊操作日志getOperationSpecialLogList】分页获取特殊操作日志信息失败",e);
        }
        return messageVO;

    }

    /**
     *<desc>
     * 获取特殊操作日志详情
     *</desc>
     *
     * @Author  chengshican
     * @Date   2020-11-10 18:41
     * @Param  log_id 逻辑ID
     * @Return
     * @Exception
     *
     */
    @RequestMapping(value = "/getOperationSpecialLogByLogId", method = RequestMethod.POST)
    @ResponseBody
    @UnAuthAccessRequired
    public Object getOperationSpecialLogByLogId(String logId){
        MessageVO messageVO;
        try{
            HttpServletRequest request= ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            logId=request.getAttribute("logId")==null?null:request.getAttribute("logId").toString();

            //判断参数合法性
            if (StringUtils.isBlank(logId)){
                return new MessageVO(OperateErrorCodeEnum.PACKAGE_UPDATE_ID_EMPTY_ERR.getErrorCode());
            }
            messageVO=new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), iOperatePackageServiceClient.getOperationSpecialLogByLogId(logId));
        }catch (Exception e){
            throw new DataAccessException("【运营_固件升级_获取分页获取特殊操作日志getOperationSpecialLogList】分页获取特殊操作日志信息失败",e);
        }
        return messageVO;

    }


    /**
    *<desc>
    * 设备升级获取设备上线下线日志
    *</desc>
    *
    * @Author  chengshican
    * @Date   2020-11-25 17:30
    * @Param
    * @Return
    * @Exception
    *
    */
    @RequestMapping(value = "/getDeviceIsOnline", method = RequestMethod.POST)
    @ResponseBody
    @UnAuthAccessRequired
    public Object getDeviceIsOnline( String deviceUnique,String pageSize, String currentPage){
        MessageVO messageVO;
        try{
            HttpServletRequest request= ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            pageSize=request.getAttribute("pageSize")==null?"5":request.getAttribute("pageSize").toString();
            currentPage=request.getAttribute("currentPage")==null?"1":request.getAttribute("currentPage").toString();
            deviceUnique=request.getAttribute("deviceUnique")==null?null:request.getAttribute("deviceUnique").toString();

            //判断参数合法性
            messageVO=new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),
                    iOperateDeviceManageServiceClient.getDeviceOnlineStatusAlterLogPage(deviceUnique,Integer.parseInt(pageSize),Integer.parseInt(currentPage)));
        }catch (Exception e){
            throw new DataAccessException("【运营_固件升级_设备升级获取设备上线下线日志getDeviceIsOnline】设备升级获取设备上线下线日志信息失败",e);
        }
        return messageVO;

    }


}
